package com.app.hmst.main;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.os.StrictMode;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.app.hmst.model.HomestayInfoVO;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;

@SuppressLint({ "NewApi", "ValidFragment" }) public class FormNotePageFragment extends Fragment{
	public View v;
	private SlidingMenu _sm;
	private ImageView menu_icon,clickToNoti;
	private HomestayInfoVO homestayInfoVO;
	private RelativeLayout gotoEvaluatePage,gotoGeneralPage;
	public FormNotePageFragment(SlidingMenu sm,HomestayInfoVO homestayInfoVO){
		this._sm = sm;
		this.homestayInfoVO = homestayInfoVO;
	}
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
		System.gc();
		StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
		StrictMode.setThreadPolicy(policy);
		
		v = inflater.inflate(R.layout.form_note_page,container, false);
		clickToNoti = (ImageView) v.findViewById(R.id.imageView9);
		clickToNoti.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				switchFragment(new ViewAllEvaluatePageFragment(_sm));
			}
		});
		gotoGeneralPage = (RelativeLayout) v.findViewById(R.id.relativeLayout2);
		gotoGeneralPage.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				switchFragment(new GeneralInfoFragment(_sm, homestayInfoVO));
			}
		});
		gotoEvaluatePage = (RelativeLayout) v.findViewById(R.id.relativeLayout3);
		gotoEvaluatePage.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				switchFragment(new EvaluateFormFragment(_sm, homestayInfoVO, true));
			}
		});
		menu_icon = (ImageView) v.findViewById(R.id.imageView6);
		menu_icon.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				_sm.toggle();
			}
		});
		new Utils(getActivity()).onBackPressed(v, new EvaluateFormFragment(_sm,homestayInfoVO,true),null);
		return v;
	}
	private void switchFragment(Fragment fragment) {
		if (getActivity() == null)
			return;

		if (getActivity() instanceof HomeStayMainActivity) {
			HomeStayMainActivity fca = (HomeStayMainActivity) getActivity();
			fca.switchContent(fragment);
		}
	}
}
